package com.linkgie.galaxyframework.httpproxy.converters;

import java.io.InputStream;

import com.linkgie.galaxyframework.httpproxy.ResponseHandler;
import com.linkgie.galaxyframework.httpproxy.ServiceInvocationContext;
import com.linkgie.galaxyframework.httpproxy.ServiceRequest;
import com.linkgie.galaxyframework.httpproxy.ServiceResponse;
import com.linkgie.galaxyframework.utils.BinaryUtils;

public class BinarySerializeResponseHandler implements ResponseHandler {

    @Override
    public Object handleResponse(ServiceRequest request, ServiceResponse response,
            ServiceInvocationContext serviceContext) throws Exception {
        // TODO: 从安全角度考虑，指定不允许序列化的类型清单；
        // String[] forbiddenClassNames = {};
        // return BinaryUtils.deserialize(responseStream, forbiddenClassNames);

        InputStream responseStream = response.getInputStream();
        return BinaryUtils.deserialize(responseStream);
    }

}